import { IPSControlAction } from '../ipscontrol-action';
import { IPSControlNavContext } from '../ipscontrol-nav-context';
import { IPSControlNavParam } from '../ipscontrol-nav-param';
import { IPSDEEditForm } from './ipsdeedit-form';
import { IPSDEWizardEditForm } from './ipsdewizard-edit-form';
import { IPSWFEditForm } from './ipswfedit-form';
import { PSDEFormImpl } from './psdeform-impl';
import { IPSDEWizardForm } from '../../dataentity/wizard/ipsdewizard-form';

export class PSDEEditFormImpl extends PSDEFormImpl implements IPSDEEditForm, IPSDEWizardEditForm, IPSWFEditForm {
  protected createpscontrolaction: IPSControlAction | null = null;

  getCreatePSControlAction(): IPSControlAction | null {
    if (this.createpscontrolaction != null) return this.createpscontrolaction;
    const value = this.M.getCreatePSControlAction;
    if (value == null) {
      return null;
    }
    this.createpscontrolaction = this.getPSControlHandlerMust().findPSControlHandlerAction(value);
    return this.createpscontrolaction;
  }

  get createPSControlAction(): IPSControlAction | null {
    return this.getCreatePSControlAction();
  }

  getCreatePSControlActionMust(): IPSControlAction {
    const value = this.getCreatePSControlAction();
    if (value == null) {
      throw new Error('未指定建立数据行为');
    }
    return value;
  }

  protected getdraftfrompscontrolaction: IPSControlAction | null = null;

  getGetDraftFromPSControlAction(): IPSControlAction | null {
    if (this.getdraftfrompscontrolaction != null) return this.getdraftfrompscontrolaction;
    const value = this.M.getGetDraftFromPSControlAction;
    if (value == null) {
      return null;
    }
    this.getdraftfrompscontrolaction = this.getPSControlHandlerMust().findPSControlHandlerAction(value);
    return this.getdraftfrompscontrolaction;
  }

  get getDraftFromPSControlAction(): IPSControlAction | null {
    return this.getGetDraftFromPSControlAction();
  }

  getGetDraftFromPSControlActionMust(): IPSControlAction {
    const value = this.getGetDraftFromPSControlAction();
    if (value == null) {
      throw new Error('未指定获取草稿数据行为（拷贝）');
    }
    return value;
  }

  protected getdraftpscontrolaction: IPSControlAction | null = null;

  getGetDraftPSControlAction(): IPSControlAction | null {
    if (this.getdraftpscontrolaction != null) return this.getdraftpscontrolaction;
    const value = this.M.getGetDraftPSControlAction;
    if (value == null) {
      return null;
    }
    this.getdraftpscontrolaction = this.getPSControlHandlerMust().findPSControlHandlerAction(value);
    return this.getdraftpscontrolaction;
  }

  get getDraftPSControlAction(): IPSControlAction | null {
    return this.getGetDraftPSControlAction();
  }

  getGetDraftPSControlActionMust(): IPSControlAction {
    const value = this.getGetDraftPSControlAction();
    if (value == null) {
      throw new Error('未指定获取草稿数据行为');
    }
    return value;
  }

  protected getpscontrolaction: IPSControlAction | null = null;

  getGetPSControlAction(): IPSControlAction | null {
    if (this.getpscontrolaction != null) return this.getpscontrolaction;
    const value = this.M.getGetPSControlAction;
    if (value == null) {
      return null;
    }
    this.getpscontrolaction = this.getPSControlHandlerMust().findPSControlHandlerAction(value);
    return this.getpscontrolaction;
  }

  get getPSControlAction(): IPSControlAction | null {
    return this.getGetPSControlAction();
  }

  getGetPSControlActionMust(): IPSControlAction {
    const value = this.getGetPSControlAction();
    if (value == null) {
      throw new Error('未指定获取数据行为');
    }
    return value;
  }

  protected gobackpscontrolaction: IPSControlAction | null = null;

  getGoBackPSControlAction(): IPSControlAction | null {
    if (this.gobackpscontrolaction != null) return this.gobackpscontrolaction;
    const value = this.M.getGoBackPSControlAction;
    if (value == null) {
      return null;
    }
    this.gobackpscontrolaction = this.getPSControlHandlerMust().findPSControlHandlerAction(value);
    return this.gobackpscontrolaction;
  }

  get goBackPSControlAction(): IPSControlAction | null {
    return this.getGoBackPSControlAction();
  }

  getGoBackPSControlActionMust(): IPSControlAction {
    const value = this.getGoBackPSControlAction();
    if (value == null) {
      throw new Error('未指定回退数据行为');
    }
    return value;
  }

  protected pscontrolnavcontexts: IPSControlNavContext[] | null = null;

  getPSControlNavContexts(): IPSControlNavContext[] | null {
    if (this.pscontrolnavcontexts == null) {
      this.pscontrolnavcontexts = this.fillChildListModel(this.M.getPSControlNavContexts, 'control.IPSControlNavContext') as IPSControlNavContext[];
    }
    return this.pscontrolnavcontexts;
  }

  get psControlNavContexts(): IPSControlNavContext[] | null {
    return this.getPSControlNavContexts();
  }

  findPSControlNavContext(objKey: any): IPSControlNavContext | null {
    return this.getPSModel5('control.IPSControlNavContext', this.getPSControlNavContexts(), objKey) as IPSControlNavContext;
  }

  protected pscontrolnavparams: IPSControlNavParam[] | null = null;

  getPSControlNavParams(): IPSControlNavParam[] | null {
    if (this.pscontrolnavparams == null) {
      this.pscontrolnavparams = this.fillChildListModel(this.M.getPSControlNavParams, 'control.IPSControlNavParam') as IPSControlNavParam[];
    }
    return this.pscontrolnavparams;
  }

  get psControlNavParams(): IPSControlNavParam[] | null {
    return this.getPSControlNavParams();
  }

  findPSControlNavParam(objKey: any): IPSControlNavParam | null {
    return this.getPSModel5('control.IPSControlNavParam', this.getPSControlNavParams(), objKey) as IPSControlNavParam;
  }

  protected psdewizardform: IPSDEWizardForm | null = null;

  getPSDEWizardForm(): IPSDEWizardForm | null {
    if (this.psdewizardform != null) return this.psdewizardform;
    const value = this.M.getPSDEWizardForm;
    if (value == null) {
      return null;
    }
    this.psdewizardform = this.getPSModel4('dataentity.wizard.IPSDEWizardForm', value, 'getPSDEWizardForm') as IPSDEWizardForm;
    return this.psdewizardform;
  }

  get psDEWizardForm(): IPSDEWizardForm | null {
    return this.getPSDEWizardForm();
  }

  getPSDEWizardFormMust(): IPSDEWizardForm {
    const value = this.getPSDEWizardForm();
    if (value == null) {
      throw new Error('未指定实体向导表单对象');
    }
    return value;
  }

  protected removepscontrolaction: IPSControlAction | null = null;

  getRemovePSControlAction(): IPSControlAction | null {
    if (this.removepscontrolaction != null) return this.removepscontrolaction;
    const value = this.M.getRemovePSControlAction;
    if (value == null) {
      return null;
    }
    this.removepscontrolaction = this.getPSControlHandlerMust().findPSControlHandlerAction(value);
    return this.removepscontrolaction;
  }

  get removePSControlAction(): IPSControlAction | null {
    return this.getRemovePSControlAction();
  }

  getRemovePSControlActionMust(): IPSControlAction {
    const value = this.getRemovePSControlAction();
    if (value == null) {
      throw new Error('未指定删除数据行为');
    }
    return value;
  }

  protected updatepscontrolaction: IPSControlAction | null = null;

  getUpdatePSControlAction(): IPSControlAction | null {
    if (this.updatepscontrolaction != null) return this.updatepscontrolaction;
    const value = this.M.getUpdatePSControlAction;
    if (value == null) {
      return null;
    }
    this.updatepscontrolaction = this.getPSControlHandlerMust().findPSControlHandlerAction(value);
    return this.updatepscontrolaction;
  }

  get updatePSControlAction(): IPSControlAction | null {
    return this.getUpdatePSControlAction();
  }

  getUpdatePSControlActionMust(): IPSControlAction {
    const value = this.getUpdatePSControlAction();
    if (value == null) {
      throw new Error('未指定更新数据行为');
    }
    return value;
  }

  protected wfstartpscontrolaction: IPSControlAction | null = null;

  getWFStartPSControlAction(): IPSControlAction | null {
    if (this.wfstartpscontrolaction != null) return this.wfstartpscontrolaction;
    const value = this.M.getWFStartPSControlAction;
    if (value == null) {
      return null;
    }
    this.wfstartpscontrolaction = this.getPSControlHandlerMust().findPSControlHandlerAction(value);
    return this.wfstartpscontrolaction;
  }

  get wFStartPSControlAction(): IPSControlAction | null {
    return this.getWFStartPSControlAction();
  }

  getWFStartPSControlActionMust(): IPSControlAction {
    const value = this.getWFStartPSControlAction();
    if (value == null) {
      throw new Error('未指定流程启动行为');
    }
    return value;
  }

  protected wfsubmitpscontrolaction: IPSControlAction | null = null;

  getWFSubmitPSControlAction(): IPSControlAction | null {
    if (this.wfsubmitpscontrolaction != null) return this.wfsubmitpscontrolaction;
    const value = this.M.getWFSubmitPSControlAction;
    if (value == null) {
      return null;
    }
    this.wfsubmitpscontrolaction = this.getPSControlHandlerMust().findPSControlHandlerAction(value);
    return this.wfsubmitpscontrolaction;
  }

  get wFSubmitPSControlAction(): IPSControlAction | null {
    return this.getWFSubmitPSControlAction();
  }

  getWFSubmitPSControlActionMust(): IPSControlAction {
    const value = this.getWFSubmitPSControlAction();
    if (value == null) {
      throw new Error('未指定流程提交行为');
    }
    return value;
  }

  get enableAutoSave(): boolean {
    return this.M.enableAutoSave != null ? this.M.enableAutoSave : false;
  }

  get infoFormMode(): boolean {
    return this.M.infoFormMode != null ? this.M.infoFormMode : false;
  }

  get readOnly(): boolean {
    return this.M.readOnly != null ? this.M.readOnly : false;
  }

  get showFormNavBar(): boolean {
    return this.M.showFormNavBar != null ? this.M.showFormNavBar : false;
  }

  get cls(): string {
    return 'PSDEEditFormImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.IPSSDAjaxControl' || cls == 'control.IPSSDControl' || cls == 'control.form.IPSDEEditForm' || cls == 'control.form.IPSDEWizardEditForm' || cls == 'control.form.IPSWFEditForm')
      return true;
    return super.instanceof(cls);
  }
}
